﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.DataAccessProvider;
using DTN.Core;

namespace com.dtn.deals
{
     public class tbl_ContactUsInfoManager: Itbl_ContactUsInfoManager
    {
        private static Itbl_ContactUsInfoManager itbl_ContactUsInfoManager = null;
        private tbl_ContactUsInfoManager()
		{
		}
		public static Itbl_ContactUsInfoManager CreateInstance()
		{
            if (itbl_ContactUsInfoManager == null)
			{
                itbl_ContactUsInfoManager = new tbl_ContactUsInfoManager();
			}
            return itbl_ContactUsInfoManager;
		}

        public int Inserttbl_ContactUs(tbl_ContactUsInfo tbl_contactUs)
        {
            DataProviderBaseClass dataProvider = DataProvider.GetDataProvider(EnumDataProviderType.SqlClient, DataHelper.GetConnectionString());
            int inumOfRowEffect = 0;
            SqlParameter[] parameters = new SqlParameter[]{
																new SqlParameter("@ID", SqlDbType.Int),
																new SqlParameter("@NameCus", SqlDbType.NVarChar),
																new SqlParameter("@EmailCus", SqlDbType.NVarChar),
																new SqlParameter("@Message", SqlDbType.NVarChar),
																new SqlParameter("@isDel", SqlDbType.TinyInt),
																new SqlParameter("@cDate", SqlDbType.DateTime),
															};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = tbl_contactUs.Namecus;
            parameters[2].Value = tbl_contactUs.EmailCus;
            parameters[3].Value = tbl_contactUs.Message;
            parameters[4].Value = tbl_contactUs.isDel;
            parameters[5].Value = tbl_contactUs.cDate;
            try
            {
                inumOfRowEffect = dataProvider.ExecuteNonQuery("sp_Inserttbl_ContactUs", CommandType.StoredProcedure, parameters);
                tbl_contactUs.ID = Convert.ToInt32(parameters[0].Value);
            }
            catch (Exception ex)
            {
                tbl_contactUs.ID = -1;
            }
            return tbl_contactUs.ID;
        }

      
    }
}
